import { tableSelectButtonClass } from '@/enums/baseConstant';

// 格式化日期时间
const formatDateTime = (row: any, column: any, cellValue: string) => {
	if (!cellValue) return '';
	// 处理日期格式，将 2025-04-16T10:47:38.3636223 转换为 2025-04-16 10:47:38
	const date = new Date(cellValue);
	const year = date.getFullYear();
	const month = String(date.getMonth() + 1).padStart(2, '0');
	const day = String(date.getDate()).padStart(2, '0');
	const hours = String(date.getHours()).padStart(2, '0');
	const minutes = String(date.getMinutes()).padStart(2, '0');
	const seconds = String(date.getSeconds()).padStart(2, '0');
	return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};

export const columns = [
	{
		label: '#',
		type: 'selection',
		fixed: 'left',
		selectable: (row: any) => !row.lockDelete,
	},
	{
		label: '序号',
		type: 'index',
		index: (index: number) => index + 1,
		width: 60,
	},
	{
		label: '课程编码',
		prop: 'code',
		minWidth: 120,
	},
	{
		label: '课程名称',
		prop: 'name',
		minWidth: 140,
	},
	{
		label: '课程描述',
		prop: 'description',
		minWidth: 180,
	},
	{
		label: '学分',
		prop: 'credit',
		minWidth: 80,
	},
	{
		label: '创建时间',
		prop: 'createTime',
		sortable: true,
		minWidth: 160,
		formatter: formatDateTime,
	},
	{
		label: '更新时间',
		prop: 'updateTime',
		sortable: true,
		minWidth: 160,
		formatter: formatDateTime,
	},
	{
		label: '创建人',
		prop: 'createdByUsername',
		minWidth: 120,
		slot: 'createUser',
	},
	{
		label: '更新人',
		prop: 'updatedByUsername',
		minWidth: 120,
		slot: 'updateUser',
	},
	{
		label: '操作',
		fixed: 'right',
		width: 320,
		slot: 'operation',
	},
];
